package com.leyou.item.mapper;

import com.leyou.item.pojo.Sku;
import com.leyou.item.pojo.Spu;
import com.leyou.item.pojo.SpuBo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author CHERRY
 * @date 2018-09-04-21:16
 */

public interface GoodsMapper extends Mapper<Spu> {
    /**
     * 根据spuId 查询spu详情
     *
     * @param spuId
     * @return
     */
    @Select("SELECT * FROM tb_spu_detail,tb_spu WHERE id = #{spuId} AND id = spu_id")
    SpuBo querySpuDetail(@Param("spuId") Long spuId);

    /**
     * 根据spuId 查询sku集合
     *
     * @param spuId
     * @return
     */
    @Select("SELECT * FROM tb_sku ,tb_stock WHERE sku_id = id AND spu_id = #{spuId}")
    //@Select("SELECT * FROM tb_sku  WHERE  spu_id = #{spuId}")
    List<Sku> querySkusBySpuId(@Param("spuId") Long spuId);

}
